<!-- 数字大屏解决方案,采用的scale的自适应解决方案 -->
<template>
  <div class="container">
    <div class="screen" ref="screen">
      <!-- 顶部区域 -->
      <div class="top">
        <top></top>
      </div>
      <!-- 底部区域 -->
      <div class="bom">
        <!-- 左侧 -->
        <div class="left">
          <!-- 游客统计 -->
          <Tourist></Tourist>

          <!-- 性别比列 -->
          <Sex></Sex>

          <!-- 年龄比列 -->
          <Age></Age>
        </div>
        <!-- 中间 -->
        <div class="center">
          <!-- 全国地图 -->
          <Map></Map>

          <!-- 折线图 -->
          <Line></Line>
        </div>
        <!-- 右边 -->
        <div class="right">
          <Ranking class="ranking"></Ranking>
          <Contrast class="contrast"></Contrast>
          <ChannelStatistics class="channelStatistics"></ChannelStatistics>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
//顶部区域
import top from "./components/Top.vue";
//底部左边组件
import Tourist from "./components/Tourist.vue";
import Sex from "./components/Sex.vue";
import Age from "./components/Age.vue";
//全国地图
import Map from "./components/map/Map.vue";
//折线图
import Line from "./components/line/Line.vue";
//热门景区排行榜
import Ranking from "./components/ranking/Ranking.vue";
//年度游客对比
import Contrast from "./components/contrast/Contrast.vue";
//渠道统计
import ChannelStatistics from "./components/channel/ChannelStatistics.vue";

//获取数据大屏展示内容盒子的DOM元素
const screen = ref();
onMounted(() => {
  screenScale();
});

//屏幕缩放时的监听
window.onresize = () => {
  screenScale();
};

//定义大屏展示区域的屏幕缩放的方法
const screenScale = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`;
};

//定义缩放方法
const getScale = (w = 1920, h = 1080) => {
  const ww = window.innerWidth / w;
  const wh = window.innerHeight / h;
  return ww < wh ? ww : wh;
};
</script>

<style lang="scss" scoped>
.container {
  width: 100%;
  height: 100%;
  background: url("./images//bg.png") no-repeat;
  background-size: cover;
  position: relative;
  .screen {
    position: absolute;
    transform-origin: left top;
    width: 1920px;
    height: 970px;
    left: 50%;
    top: 50%;
    display: flex;
    flex-direction: column;

    .top {
      width: 100%;
    }

    .bom {
      width: 100%;
      flex: 1;
      display: flex;

      .left {
        flex: 1;
        display: flex;
        flex-direction: column;
      }

      .center {
        flex: 3;
        display: flex;
        flex-direction: column;
      }
      .right {
        flex: 1;
        display: flex;
        flex-direction: column;

        .ranking {
          flex: 1.3;
          background: url(./images/dataScreen-main-lb.png) no-repeat;
          background-size: 100% 100%;
        }
        .contrast {
          margin-top: 20px;
          flex: 1;
          background: url(./images/dataScreen-main-lb.png) no-repeat;
          background-size: 100% 100%;
        }
        .channelStatistics {
          margin-top: 20px;
          flex: 1;
          background: url(./images/dataScreen-main-lb.png) no-repeat;
          background-size: 100% 100%;
        }
      }
    }
  }
}
</style>
